<template>
  <div>
    <div class="header_search_nav search_form">
      <div class="ipt_left">
        <el-form ref="queryForm" :model="queryParams" label-width="80px">
          <el-row>
            <el-col :span="6">
              <el-form-item label="门店" prop="storeIds">
                <el-select
                  v-model="queryParams.storeIds"
                  placeholder="请选择"
                  filterable
                  multiple
                  collapse-tags
                  class="w-300"
                >
                  <el-option
                    v-for="(item, index) in $store.state.user.stores"
                    :key="index"
                    :label="item.name"
                    :value="item.id"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="6">
              <div class="timebox">
                <el-form-item label="日期时间" prop="date">
                  <timer
                    ref="timer"
                    :timer.sync="queryParams.date"
                    @query="handleQuery"
                  ></timer>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
        </el-form>
      </div>

      <div class="btn_right">
        <button class="btn1" @click="handleQuery">筛选</button>
        <button class="btn2" @click="resetQuery">重置</button>
      </div>
    </div>
    <div class="table_card">
      <!-- 上部分 title -->
      <div class="table_card_top">
        <span class="solid_left1"></span>
        <div class="table_card_title">营收合计(多)</div>
        <div class="op_right"></div>
      </div>

      <div class="table_list">
        <el-table
          :data="AmountSedList"
          stripe
          style="width: 100%"
          v-loading="loading"
        >
          <el-table-column
            prop="storeName"
            label="门店名称"
            width="160px"
            fixed="left"
          >
          </el-table-column>
          <el-table-column prop="totalCount" label="当日合计" width="160px">
          </el-table-column>
          <!-- <el-table-column prop="thCount" label="美团口碑量" width="150px">
          </el-table-column> -->
          <el-table-column prop="newCount" label="新客量"> </el-table-column>
          <el-table-column prop="custCount" label="会员量"> </el-table-column>
          <el-table-column prop="backCount" label="回客量"> </el-table-column>
          <el-table-column prop="itemCount" label="项目量"> </el-table-column>
          <el-table-column
            prop="rechargeMoneyTotal"
            label="当日充值总金额"
            width="130px"
          >
          </el-table-column>
          <el-table-column
            prop="giveMoneyTotal"
            label="当日赠送总金额"
            width="130px"
          >
          </el-table-column>
          <el-table-column prop="cardConsumeTotal" label="扣卡">
          </el-table-column>
          <el-table-column prop="wxTotal" label="微信"> </el-table-column>
          <el-table-column prop="zfbTotal" label="支付宝"> </el-table-column>
          <el-table-column prop="posTotal" label="刷卡"> </el-table-column>
          <el-table-column prop="rmbTotal" label="现金"> </el-table-column>
          <el-table-column prop="mtTotal" label="美团收款"> </el-table-column>
          <el-table-column prop="channelMtTotal" label="美团">
          </el-table-column>
          <el-table-column prop="channelDyTotal" label="抖音">
          </el-table-column>
          <el-table-column prop="channelKbTotal" label="口碑">
          </el-table-column>
          <el-table-column prop="channelKsTotal" label="快手">
          </el-table-column>

          <el-table-column
            prop="incomeTotal"
            label="当日收入总金额(元)"
            width="140px"
          >
          </el-table-column>
          <el-table-column prop="cardTotal" label="总扣款(元)" width="120px">
          </el-table-column>
          <!-- <el-table-column
            label="操作"
            align="center"
            fixed="right"
            class-name="small-padding fixed-width"
          >
            <template slot-scope="scope">
              <el-button size="mini" type="text" @click="open(scope.row)"
                >渠道支付详情</el-button
              >
            </template>
          </el-table-column> -->
        </el-table>
        <!-- <pagination
            :total="total"
            :page.sync="queryParams.pageNo"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
          /> -->
      </div>
    </div>
  </div>
</template>

<script>
import { getAmountAdmin } from "@/api/bpm/report";
import { dayDataTime } from "@/utils/utils";
import timer from "@/components/getTime/timer";
import { startAndEnd } from "@/api/bpm/time";
export default {
  name: "Storeadminrevenuetotalsed",
  components: { timer },
  data() {
    return {
      AmountSedList: [],
      loading: false,

      value: "",
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        // localDate: "",
        // storeId: "",
        date: [],
        storeIds: [],
        startTime: "",
        endTime: "",
      },
      total: 0,
    };
  },

  mounted() {},

  created() {
    // this.resetQuery();
  },

  methods: {
    // 筛选
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },

    /** 重置按钮操作 */
    resetQuery() {
      this.resetFormData("queryForm");
      this.queryParams.localDate = dayDataTime("obj").str;
      this.queryParams.date = [];
      this.handleQuery();
    },

    // 表单重置
    resetFormData(formName) {
      console.log(this.$refs[formName]);
      this.$nextTick(() => {
        this.$refs[formName].resetFields();
      });
    },

    // 营收合计
    getList() {
      this.loading = true;
      const query = JSON.parse(JSON.stringify(this.queryParams));

      if (!!query.date) {
        query.startTime = this.queryParams.date[0];
        query.endTime = this.queryParams.date[1];
        query.date = [];
      }

      getAmountAdmin(query)
        .then((res) => {
          console.log(res);
          this.loading = false;
          const { code, data } = res;
          if (code === 0) {
            this.AmountSedList = data;
            this.total = data.total;
          }
        })
        .catch((err) => {
          this.loading = false;
        });
    },

    open(row) {
      const { cardMoneyTotalVoList } = row;
      const h = this.$createElement;
      let arry = cardMoneyTotalVoList.map((item) => {
        return h("p", null, item.cardTypeName + "：￥" + item.cardMoney);
      });

      this.$msgbox({
        title: "渠道支付",
        message: h("p", null, arry),
        showCancelButton: false,
        showConfirmButton: false,
        beforeClose: (action, instance, done) => {
          done();
        },
      }).then((action) => {});
    },
  },
};
</script>

<style lang="scss" scoped>
.solid_left1 {
  margin-left: 24px;
}
.goodTop {
  width: 100%;
  height: 48px;
  background: #ffffff;
  display: flex;
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.6);
  line-height: 48px;
  padding-left: 16px;
  .good_list {
    margin-right: 32px;
  }

  .good_active {
    color: #0052d9;
    border-bottom: 1px solid #0052d9;
  }
}

.w-200 {
  width: 200px;
  background: #ffffff;
  border-radius: 4px;
}

.client_name {
  font-size: 14px;
  font-weight: 400;
  color: #0052d9;
}

.give {
  height: 40px;
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.85);
  margin-top: 40px;
  line-height: 40px;
}

.el-form-item {
  margin-bottom: 20px;
}

.recharge_form {
  padding: 10px 24px;
}

.memberName {
  font-size: 14px;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.85);
}
.el_row_item {
  margin-bottom: 10px;
}
.el_row_date {
  margin-top: 20px;
}
.el_row_reason {
  margin-top: 10px;
}

.el_row_date {
  .el-form-item {
    margin-bottom: 0px;
  }
}

.Order_box {
  display: flex;
  margin-left: -50px;
  .select_ipt {
    width: 130px;
    margin-right: 10px;
  }
}

.pay_ipt {
  margin-left: 50px;
}

.order_ipt {
  margin-left: -120px;
}

.table_list {
  padding-bottom: 24px;
}
</style>
